export function randomInt(min, max) {  //生成一个[min, max)之间的随机整数
    return Math.floor(Math.random() * (max - min)) + min
}

// console.log(Math.random());  // 0-1之间的随机数

// const articleLength = randomInt(3000, 5000)
// const sectionLength = randomInt(200, 500)

export function createRandomPicker(arr) {
    arr = [...arr]

    function randomPick() {
        const len = arr.length - 1
        const index = randomInt(0, len)
        const picked = arr[index];
        [arr[index], arr[len]] = [arr[len], arr[index]]
        return picked
    }
    randomPick()  //抛弃第一次的选中结果
    return randomPick
}